<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
	<head>
		<title>Allocine View 2.5</title>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859">
		<script src="AC_QuickTime.js"></script>
		<link href="style.css" rel="stylesheet" />
		<script>
			function getXhr() {
				var xhr = null;
				if(window.XMLHttpRequest)// Firefox et autres
					xhr = new XMLHttpRequest();
				else if(window.ActiveXObject) {// IE
					try {
						xhr = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						xhr = new ActiveXObject("Microsoft.XMLHTTP");
					}
				} else {// XMLHttpRequest non support� par le navigateur
					alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
					xhr = false;
				}
				return xhr
			}

			function recup_allocine(film, path) {
				document.getElementById("info_film").innerHTML = "<br/> <br/> <br/> <br/> <br/><br/> <br/> <br/> <br/> <br/> <center><img src='load.gif'><span style='font-size:25'>Chargement....</sopan></center>";
				var xhr = getXhr();
				// On d�fini ce qu'on va faire quand on aura la r�ponse
				xhr.onreadystatechange = function() {
					//serveur ok?
					if(xhr.readyState == 4 && xhr.status == 200) {
						information = xhr.responseText + "<br /><embed src='" + path + "' width=600 height=400 autostart='false' loop=1>";
						// On se sert de innerHTML pour rajouter les options a la liste
						document.getElementById("info_film").innerHTML = information;
						document.getElementById("info_film").style.visibility = "visible";
					}
				}
				xhr.open("POST", "ajax.php", true);
				xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xhr.send("film=" + film);
			}
		</script>
		<style type="text/css" title="currentStyle">
			@import "DataTables-1.8.2/media/css/demo_table.css";
		</style>
		<script type="text/javascript" language="javascript" src="DataTables-1.8.2/media/js/jquery.js"></script>
		<script type="text/javascript" language="javascript" src="DataTables-1.8.2/media/js/jquery.dataTables.js"></script>
		<script type="text/javascript" charset="ISO-8859">
			$(document).ready(function() {
				$('#selectable').dataTable({
					"aaSorting" : [[1, "desc"]],
					"sScrollY" : "700px",
					"aoColumnDefs" : [{
						"bSearchable" : true,
						"bVisible" : false,
						"aTargets" : [2]
					}],
					"bPaginate" : false
				});
			});

		</script>
	</head>
	<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
		<?
		function stripAccents($string) {
			return strtr($string, '���������������������������������������������������', 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
		}

		$dirname = 'I:\divx';
		$dir = opendir($dirname);
		$tab_film = array();
		$nom = "";
		$dirname2 = "";
		while ($file = readdir($dir)) {
			if ($file != '.' && $file != '..' && !is_dir($dirname . '\\' . $file)) {
				$nom = strtolower($file);
				$nom = str_replace('.avi', '', $nom);
				$nom = str_replace('.mkv', '', $nom);
				$nom = str_replace('.', ' ', $nom);
				$nom = str_replace('-', ' ', $nom);
				$nom = str_replace('_', ' ', $nom);
				$nom = str_replace("'", ' ', $nom);
				$dirname2 = str_replace("\\", '\\\\', $dirname);
				$tab_film[] = $nom . '|' . $dirname2 . '\\\\' . $file . '|' . date("Y-m-d", filemtime($dirname . '\\' . $file));

			}
			if ($file != '.' && $file != '..' && is_dir($dirname . '\\' . $file)) {
				$dir2 = opendir($dirname . '\\' . $file);
				while ($file2 = readdir($dir2)) {
					if ($file2 != '.' && $file2 != '..' && !is_dir($dirname . '\\' . $file . '\\' . $file2)) {
						$nom = strtolower($file2);
						$nom = str_replace('.avi', '', $nom);
						$nom = str_replace('.mkv', '', $nom);
						$nom = str_replace('.', ' ', $nom);
						$nom = str_replace('-', ' ', $nom);
						$nom = str_replace('_', ' ', $nom);
						$nom = str_replace("'", ' ', $nom);
						$dirname2 = str_replace("\\", '\\\\', $dirname);
						$tab_film[] = $nom . '|' . $dirname2 . '\\\\' . $file . '\\\\' . $file2 . '|' . date("Y-m-d", filemtime($dirname . '\\' . $file . '\\' . $file2));

					}
				}
			}
		}
		sort($tab_film);
		closedir($dir);
		echo '
		<table cellspacing="0" cellpadding="0" style="margin:0 auto;" >
			<tr>
				<td valign="top" align="center">
				<div style="margin:0 auto;text-align:center;">
					<table cellpadding="0" cellspacing="0" border="0" style="margin-left:20px"  class="display"  id="selectable">
						<thead>
							<tr>
								<th>Titre</th>
								<th>Date</th>
								<th>Emplacement</th>
							</tr>
						</thead>
						<tbody>
							';
		foreach ($tab_film as $film) {
			echo '
							<tr>
								';
			list($name, $path, $date) = explode("|", $film);
			echo '<td><a href="javascript:recup_allocine(\'' . stripAccents($name) . '\',\'' . $path . '\')">
								<div style="width:200px;">
									&nbsp;' . $name . '
								</div></a></td>';
			echo '<td style="font-size:11px">' . $date . '</td>';
			echo '<td style="font-size:11px">' . $path . '</td>';
			echo '
							</tr>
							';
		}
	?>
						</tbody>
					</table>
					<br />
					<br />
					<br />
					<div style='padding-top:20px;text-align:center;margin:0 auto;font-size:20px'>
						Allociné View 2.5 by Qw3nY
					</div>
				</div></td><td valign='top' align='center' width='930px'>
				<div id="info_film" >
					<br />
					<br />
					<br />
					<br />
					<br />
					Selectionner un film !
				</div></td>
			</tr>
		</table>
	</body>
</html>